package chesskers;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.util.ArrayList;

import javax.swing.JLabel;
import javax.swing.JPanel;
 
public class ImagePanel extends JPanel {
	private ArrayList<ImageContainer> imgs;
 
 
      public ImagePanel(Image img) {
    	  setLayout(null);
    	  imgs = new ArrayList<ImageContainer>();
    	  imgs.add(new ImageContainer(img, 0, 0));
	      Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
	      setPreferredSize(size);
	      setMinimumSize(size);
	      setMaximumSize(size);
	      setSize(size);
      }
      
      public void ResetToBackground(){
    	  ImageContainer spare = imgs.get(0);
    	  imgs = new ArrayList<ImageContainer>();
    	  imgs.add(spare);
      }
      
      public void AddImage(Image img, int x, int y){
    	  imgs.add(new ImageContainer(img, x, y));
      }
 
      public void paintComponent(Graphics g) {
    	  for (int i = 0; i < imgs.size(); i++){
    		  g.drawImage(imgs.get(i).img, imgs.get(i).x, imgs.get(i).y, null);
    	  }
      }
}
